package zhihui.mobile.ui.shop.web;

import android.content.Intent;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.zgm.utils.ui.UiTextHeader;

import java.util.logging.MemoryHandler;

import zhihui.mobile.R;
import zhihui.mobile.config.Config;
import zhihui.mobile.presenter.IPresenter;
import zhihui.mobile.presenter.shop.ShopWebPresenter;
import zhihui.mobile.ui.BaseActivity;

/**
 * Created by 张公铭 on 2017/7/26 0026.
 */

public class ShopWebActivity extends BaseActivity implements IShopWebContract.IShopWebView
{
    private IShopWebContract.IShopWebPresenter webPresenter = new ShopWebPresenter();
    private String url = "http://u31737817.b2bname.com/";
    private UiTextHeader mheader;
    private WebView wv_view;

    @Override
    public void initView()
    {
        mheader = (UiTextHeader) findViewById(R.id.header_web);
        mheader.setTitle("活动介绍");
        mheader.setLeftBottonIcon(R.drawable.shop_back);
        mheader.setLeftButtonOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                goBack(ShopWebActivity.class);
            }
        });
        mheader.hindRight();

        wv_view = (WebView) findViewById(R.id.wv_web);
        wv_view.loadUrl(url);
        wv_view.setWebViewClient(new WebViewClient()
        {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url)
            {
                view.loadUrl(url);
                return true;
            }
        });
    }

    @Override
    protected void parseArgumentsFormIntent(Intent argIntent)
    {
        url = argIntent.getStringExtra("url");
    }

    @Override
    protected int getLayoutResId()
    {
        return R.layout.web_activity;
    }

    @Override
    protected IPresenter[] getPresenters()
    {
        return new IPresenter[]{ webPresenter };
    }

    @Override
    protected void onInitPresenter()
    {
        webPresenter.init(this, this);
    }
}
